package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.BaseCodeValueService;
import com.yixun.qfbao.apidto.EditBaseCodeValueReqDto;
import com.yixun.qfbao.apidto.EditBaseCodeValueResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.EditBaseCodeValueReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 类型值修改
 * @author guifang.weng
 * @create 2017-11-24 10:33
 **/
@Service
public class EditBaseCodeValueHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(EditBaseCodeValueHander.class);

    @Autowired
    private BaseCodeValueService baseCodeValueService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        BaseResponseDTO<EditBaseCodeValueResDto> res = new BaseResponseDTO<>();
        EditBaseCodeValueReqVo reqVo = (EditBaseCodeValueReqVo)reqDto;
        EditBaseCodeValueReqDto editBaseCodeValueReqDto = reqVo.getParams();
        try {
            EditBaseCodeValueResDto resDto = baseCodeValueService.editBaseCodeValue(editBaseCodeValueReqDto);
            res.setResult(resDto.getResult());
            res.setResData(resDto);
        } catch (Exception e) {
            logger.error("EditBaseCodeValueHander error: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("修改类型值失败");
        }
        return res;
    }
}
